package com.epam.xml.checker;

import java.io.IOException;

import org.apache.log4j.Logger;
import org.apache.log4j.chainsaw.Main;
import org.apache.xerces.parsers.DOMParser;
import org.xml.sax.SAXException;
import org.xml.sax.SAXNotRecognizedException;
import org.xml.sax.SAXNotSupportedException;

public class Checker {
	private static Logger logger = Logger.getLogger(Checker.class);
	
	public static void main(String[] args) {
		String filename = Main.class.getClass().getResource("/Clients.xml").getPath();
		DOMParser parser = new DOMParser();
		try {
			parser.setErrorHandler(new MyErrorHandler());
			parser.setFeature("http://xml.org/sax/features/validation", true);
			parser.setFeature("http://apache.org/xml/features/validation/schema", true);
			parser.parse(filename);
		} catch (SAXNotRecognizedException e) {
			e.printStackTrace();
			logger.error("Identificator was not recognized!");
		} catch (SAXNotSupportedException e) {
			e.printStackTrace();
			logger.error("Operation is not supported!");
		} catch (SAXException e) {
			e.printStackTrace();
			logger.error("Global SAX error!");
		} catch (IOException e) {
			e.printStackTrace();
			logger.error("IO error!");
		}
		
		
	}
}
